package hk.mars.controller;

import hk.mars.domain.UserEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Mars(qingke.hk @ gmail.com)
 * @version 0.0.1
 * @date 2018/12/07
 */

@RestController
public class UserEntityController {

    @RequestMapping("/user")
    public List<UserEntity> getUserList() {
        List<UserEntity> userList = new ArrayList<>(3);
        userList.add(new UserEntity(1, "小李", "123456789"));
        userList.add(new UserEntity(2, "夏明", "123456789"));
        userList.add(new UserEntity(3, "小白", "123456789"));

        return userList;
    }

    @RequestMapping("/user/{id}")
    public UserEntity getUser(@PathVariable("id") int userId) {
        return new UserEntity(userId, "小白", "123456789");
    }

    @Override
    public String toString() {
        return "this is a test";
    }
}
